<template>
  <div class="my-services-container">
    <div class="service-menu">
      <el-menu
        :default-active="activeMenu"
        @select="handleMenuSelect"
        class="menu-list"
      >
        <el-menu-item index="account">
          <el-icon><User /></el-icon>
          <span>个人账号服务</span>
        </el-menu-item>
        <el-menu-item index="tours">
          <el-icon><Tickets /></el-icon>
          <span>个人旅游团服务</span>
        </el-menu-item>
        <el-menu-item index="posts">
          <el-icon><Document /></el-icon>
          <span>个人文章服务</span>
        </el-menu-item>
        <el-menu-item index="comments">
          <el-icon><ChatDotRound /></el-icon>
          <span>个人评论服务</span>
        </el-menu-item>
        <el-menu-item index="weather">
          <el-icon><Sunny /></el-icon>
          <span>天气查询服务</span>
        </el-menu-item>
      </el-menu>
    </div>

    <div class="service-content">
      <router-view></router-view>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { User, Tickets, Document, ChatDotRound, Sunny } from '@element-plus/icons-vue'

const router = useRouter()
const route = useRoute()

const activeMenu = computed(() => {
  if (route.matched.length > 1) {
    return route.matched[route.matched.length - 1].path.split('/').pop()
  }
  return 'account'
})

const handleMenuSelect = (key: string) => {
  switch (key) {
    case 'account':
      router.push('/my-services/account')
      break
    case 'tours':
      router.push('/my-services/tours')
      break
    case 'posts':
      router.push('/my-services/posts')
      break
    case 'comments':
      router.push('/my-services/comments')
      break
    case 'weather':
      router.push('/my-services/weather')
      break
  }
}
</script>

<style scoped>
.my-services-container {
  display: flex;
  min-height: calc(100vh - 64px);
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  gap: 20px;
  box-sizing: border-box;
}

.service-menu {
  width: 200px;
  flex-shrink: 0;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 84px;
  height: fit-content;
}

.menu-list {
  border-right: none;
  border-radius: 8px;
}

.service-content {
  flex: 1;
  background-color: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  min-width: 0;
}
</style> 